
var userName=document.getElementById("import"); 
var array= document.getElementsByTagName("span");
var textArea=document.getElementById("cmt");
var pHtml=document.getElementById("wrt");
var textNow=document.getElementsByTagName("i")[0];
var uNow=document.getElementsByTagName("u")[0];
var bigLast=document.getElementById("big");   
console.log(textArea)
textArea.onkeyup = function(){
    var textarea=textArea.value.trim();
    console.log(textarea.length);
    if(textarea.length<=150){
        uNow.innerHTML= "还能输入"
        textNow.innerHTML=(150-textarea.length);
    } else{
        uNow.innerHTML="已超出";
        textNow.style.color="red";
        textNow.innerHTML=(textarea.length-150);
    }
}
function tijiao(){
    textarea=textArea.value.trim();
   var username=userName.value;
    if(username.length>8 || username.trim().length==0){
        alert("您输入的昵称不合理，请重新输入");
        return;
    }
    if(textarea.length==0){
        alert("内容输入为空");
        return;
    }
    if(textarea.length>150){
        alert("你输入的字数太多，超出" + (textarea.length - 150)+"个字");
        return;
    }
    textArea.value="";
    userName.value="";
    createThings();
}
function spanOn (a){
    for(var i = 0; i< array.length; i++);{
         array[i].className="";
         array[a].className="spanname";
    }
}
setInterval(function(){
    var arrayDiv=document.querySelectorAll("#big>div");
    var delbutton=document.querySelectorAll("#big>div>input");
    for( i = 1; i < arrayDiv.length; i++){
        cansole.log(delbutton[i-1]);
        arrayDiv[i].onmouseover=function(){
            delbutton[i-1].style.display="block";
        }
        arrayDiv[i].onmouseleave=function(){
            delbutton[i-1].style.display="none";  
        }
        delbutton[i-1].onlick=function(){
            arrayDiv[i].style.display="none";
        }
    }
},2000)

function createThings () {
	var photoGet=document.querySelector(".spanOne>img");
	var divLast=document.createElement("div");
	var imgLast=document.createElement("img");
	var iLast=document.createElement("i");
	var uLast=document.createElement("u");
	var dateLast=document.createElement("span");
	var nowdate=new Date();
	var month=nowdate.getMonth()+1;
	var day=nowdate.getDate();
	var hour=nowdate.getHours();
	var min=nowdate.getMinutes();
	var time=month+"月"+day+"日"+" "+hour+":"+min;
	dateLast.innerHTML=time;
	imgLast.src=photoGet.src;
	iLast.innerHTML=username+":";
	uLast.innerHTML=textarea+"。";
	footerLast.appendChild(divLast);
	divLast.appendChild(imgLast);
	divLast.appendChild(iLast);
	divLast.appendChild(uLast);
	divLast.appendChild(dateLast);
	var btn=document.createElement("input");
	btn.value="删除";
	btn.type="button";
	divLast.appendChild(btn);
}
